//
//  BuyLotteryOperation.m
//  PlayBall
//
//  Created by Edward Zhang on 12-6-10.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddBuyLotteryOperation.h"

@implementation JddBuyLotteryOperation

@synthesize lotteryTypeId;
@synthesize issueId;
@synthesize multiple;
@synthesize moneyAmount;
@synthesize lotteryNumber;

- (void)main{
    
    @autoreleasepool {
        
        JddNetDataCommunication *netDataCommunication = [[JddNetDataCommunication alloc] init];
        
        NSString *bodyString = [JddParameterBuilder buyLotteryOfTypeId:self.lotteryTypeId
                                                               issueId:self.issueId
                                                              multiple:self.multiple
                                                           moneyAmount:self.moneyAmount
                                                         lotteryNumber:self.lotteryNumber];
        
        NSData *dataLotteryIssue = [netDataCommunication requestDataByPostBodyDataGouCai:[bodyString dataUsingEncoding:NSUTF8StringEncoding]];
    
        NSString *resultDataString = [[NSString alloc] initWithData:dataLotteryIssue encoding:NSUTF8StringEncoding];
        //NSLog(@"resultDataString=%@",resultDataString);
        /*
        NSDictionary *ReDic = [NSJSONSerialization JSONObjectWithData:dataLotteryIssue options:NSJSONReadingMutableContainers error:nil];
        if([[ReDic objectForKey:@"Code"] intValue] == 0)
        {
            NSString*checkUrlString = [NSString stringWithFormat:@"%@?ck=%@",BASE_SERVER_IOS_BUY_LOTTERY_URL,[ReDic objectForKey:@"Data"]];
            NSURL *checkUrl = [NSURL URLWithString:checkUrlString];
            [[UIApplication sharedApplication] openURL:checkUrl];
        }*/
        
        [((NSObject*)self.delegate) performSelectorOnMainThread:@selector(BuyLotteryOperationResult:) withObject:dataLotteryIssue waitUntilDone:NO];
        
    }
}

@end
